import { BaseItem } from "../common/BaseItem";
import { ItemData } from "../../resource/info/ItemData";
import { ItemsUtil } from "../shortcuts/item/ItemsUtil";
import { PetMingBaseItem } from "../pet/ming/PetMingBaseItem";
import { IDragDrop } from "../../../../com/mui/manager/IDragDrop";
import { PackItem } from "../pack/PackItem";
import { EBind } from "../../../../Message/Public/EBind";
import { DragManager } from "../../../../com/mui/manager/DragManager";
//class AttachmentItem
    
    export  class AttachmentItem extends BaseItem
    {
        constructor()
        {
            super();
            this.isShowLock = true;
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMh);
            return;
        }

        /* internal  */onMh(arg1: Object /* flash.events.MouseEvent */): void
        {
            return;
        }

        public /* override */ get dragSource(): Object
        {
            return this._dragSource;
        }

        public /* override */ set dragSource(arg1: Object)
        {
            if (arg1) 
            {
                if (typeof arg1 === "itemdata") 
                {
                    if (ItemsUtil.isPetLifeStyle(arg1 as ItemData)) 
                    {
                        if (!this._mingBaseItem) 
                        {
                            this._mingBaseItem = new PetMingBaseItem();
                            this._mingBaseItem.isShowName = false;
                            this._mingBaseItem.isShowLevel = false;
                            this._mingBaseItem.isDragAble = false;
                            this._mingBaseItem.isDropAble = false;
                        }
                        this._mingBaseItem.x = -11;
                        this._mingBaseItem.y = -13;
                        if (!this.contains(this._mingBaseItem)) 
                        {
                            this.addChild(this._mingBaseItem);
                        }
                        this._mingBaseItem.mouseEnabled = true;
                        this._mingBaseItem.itemData = arg1 as ItemData;
                        this.toolTipType = ItemData.ToolTipType_PetLifeStyle;
                    }
                    else 
                    {
                        if (this._mingBaseItem && this.contains(this._mingBaseItem)) 
                        {
                            this.removeChild(this._mingBaseItem);
                        }
                        toolTipType = ItemData.ToolTipType_Pack;
                    }
                    this.itemData = arg1 as ItemData;
                }
            }
            else 
            {
                this.itemData = null;
            }
            this._dragSource = arg1;
            return;
        }

        public /* override */ canDrop(arg1: IDragDrop, arg2: IDragDrop): Boolean
        {
            var loc2=null;
            var loc3=null;
            var loc1=arg1 as BaseItem;
            if (loc1) 
            {
                if (typeof arg1 === "packitem") 
                {
                    loc2 = arg1 as PackItem;
                    if ((loc3 = new ItemData(loc2.itemData.data)).itemInfo.item.bind != EBind._EBindYes) 
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        protected /* override */ onMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.isDragAble) 
            {
                DragManager.instance.startDragItem(this);
            }
            return;
        }

        public detory(): void
        {
            this.dragSource = null;
            this.amount = 0;
            this.amountLabel.text = "";
            if (this._mingBaseItem) 
            {
                this._mingBaseItem.itemData = null;
            }
            return;
        }

        /* internal */ /* var */_dragSource: Object;

        /* internal */ /* var */_mingBaseItem: PetMingBaseItem;
    }
